package com.kly.chatter.api.application.controller.chatter.res;

import com.amazonaws.services.dynamodbv2.xspec.S;
import com.fqgj.common.utils.CollectionUtils;
import com.kly.user.dto.chatter.response.ChatterModelsUnreadMsgDto;
import com.kly.user.dto.chatter.response.ChatterModelsUnreadMsgDtoItem;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class ChatterModelsUnreadMsgRes implements Serializable {

    private static final long serialVersionUID = 819316395988521968L;
    private List<Item> models = new ArrayList<>();

    private String news = "";

    private Integer totalUnreadMsg = 0;

    public ChatterModelsUnreadMsgRes() {
    }

    public ChatterModelsUnreadMsgRes(List<ChatterModelsUnreadMsgDtoItem> modelsFinal) {
        if (CollectionUtils.isEmpty(modelsFinal)) {
            return;
        }


        modelsFinal.forEach(m -> {
            models.add(
                    new Item()
                            .setNickName(m.getNickName())
                            .setToken(m.getToken())
                            .setAvatarUrl(m.getAvatarUrl())
                            .setModelCode(m.getModelCode())
                            .setUnReadNum(m.getUnReadNum())
            );
        });

        for (int i = 0; i < modelsFinal.size(); i++) {
            totalUnreadMsg += modelsFinal.get(i).getUnReadNum();
        }


    }


    public Integer getTotalUnreadMsg() {
        return totalUnreadMsg;
    }

    public ChatterModelsUnreadMsgRes setTotalUnreadMsg(Integer totalUnreadMsg) {
        this.totalUnreadMsg = totalUnreadMsg;
        return this;
    }

    public String getNews() {
        return news;
    }

    public ChatterModelsUnreadMsgRes setNews(String news) {
        this.news = news;
        return this;
    }

    public List<Item> getModels() {
        return models;
    }

    public ChatterModelsUnreadMsgRes setModels(List<Item> models) {
        this.models = models;
        return this;
    }

    public class Item implements Serializable {
        private static final long serialVersionUID = -4552195978500135328L;
        private String avatarUrl;

        private String nickName;

        private Integer unReadNum;

        private String token;

        private String modelCode;

        public String getModelCode() {
            return modelCode;
        }

        public Item setModelCode(String modelCode) {
            this.modelCode = modelCode;
            return this;
        }

        public String getAvatarUrl() {
            return avatarUrl;
        }

        public Item setAvatarUrl(String avatarUrl) {
            this.avatarUrl = avatarUrl;
            return this;
        }

        public String getNickName() {
            return nickName;
        }

        public Item setNickName(String nickName) {
            this.nickName = nickName;
            return this;
        }

        public Integer getUnReadNum() {
            return unReadNum;
        }

        public Item setUnReadNum(Integer unReadNum) {
            this.unReadNum = unReadNum;
            return this;
        }

        public String getToken() {
            return token;
        }

        public Item setToken(String token) {
            this.token = token;
            return this;
        }
    }

}
